#!/bin/bash

if [ -d ./code ]
then
   echo 'Deleting *.pyc files from /code'
   rm ./code/*.pyc 2>/dev/null
fi

if [ -d ./tool ]
then
   echo 'Deleting *.pyc files from /tool'
   rm ./tool/*.pyc 2>/dev/null
fi

echo
tar -cvf mapreduce-cccgistemp.tar code/ tool/

if [ -f ./mapreduce-cccgistemp.tar ]
then
   gzip mapreduce-cccgistemp.tar
   if [ -f ./mapreduce-cccgistemp.tar.gz ]
   then
       echo 'Code archive successfully created'
   else
       echo 'Failed to compress the zipped file'
   fi
else
   echo 'Failed to generate mapreduce-cccgistemp.tar file'
fi
